package com.volokh.danylo.utils;

import com.ohos.RecyclerContainer;
import com.volokh.danylo.layoutmanager.circle_helper.circle_points_creator.FirstQuadrantCirclePointsCreator;
import com.volokh.danylo.layoutmanager.circle_helper.point.Point;
import ohos.agp.components.AttrSet;
import ohos.agp.render.Canvas;
import ohos.agp.render.Paint;
import ohos.agp.utils.Color;
import ohos.app.Context;

import java.util.LinkedHashMap;

public class DebugRecyclerView extends RecyclerContainer {
    private static final String TAG = DebugRecyclerView.class.getSimpleName();

    private Paint mPaintForCircle;
    private Paint mPaintForCross;

    private int mRadius;

    private int mXOrigin;
    private int mYOrigin;

    private FirstQuadrantCirclePointsCreator mCirclePointsCreator;

    private LinkedHashMap<Integer, Point> mCircleIndexPoint;
    private LinkedHashMap<Point, Integer> mCirclePointIndex;

    public DebugRecyclerView(Context context) {
        super(context);
        init();
    }

    public DebugRecyclerView(Context context, AttrSet attrs) {
        super(context, attrs);
        init();

    }

    public DebugRecyclerView(Context context, AttrSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init();
    }

    public void setParameters(int radius, int xOrigin, int yOrigin){
        mRadius = radius;
        mXOrigin = xOrigin;
        mYOrigin = yOrigin;

        mCircleIndexPoint = new LinkedHashMap<>();
        mCirclePointIndex = new LinkedHashMap<>();

        mCirclePointsCreator = new FirstQuadrantCirclePointsCreator(mRadius, mXOrigin, mYOrigin);
        mCirclePointsCreator.fillCirclePoints(mCircleIndexPoint, mCirclePointIndex);

        invalidate();
    }

    private void init() {
        mPaintForCircle = new Paint();
        mPaintForCircle.setColor(Color.BLACK);
        mPaintForCircle.setAlpha(0.4f /*This is not percents*/);

        mPaintForCross = new Paint();
        mPaintForCross.setColor(Color.BLACK);
        mPaintForCross.setStrokeWidth(5);
    }
}
